
package kaizone.haining.chaobohui.widget;

import kaizone.haining.chaobohui.R;
import kaizone.haining.chaobohui.util.ImageFetcher;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CBHItemTushuo extends LinearLayout {

    private ImageView mImageView;

    private TextView mTextView;
    
    private TextView mTextView02;

    public CBHItemTushuo(Context context) {
        super(context);
    }

    public CBHItemTushuo(Context context, AttributeSet attrs) {
        super(context, attrs);
        init();
    }

    private void init() {

    }

    @Override
    protected void onFinishInflate() {
        super.onFinishInflate();
        mImageView = (ImageView) findViewById(R.id.img);
        mTextView = (TextView) findViewById(R.id.tv01);
        mTextView02 = (TextView) findViewById(R.id.tv02);
    }
    
    @Override
    public void updateViewLayout(View view, android.view.ViewGroup.LayoutParams params) {
        super.updateViewLayout(view, params);
    }

    @Override
    protected void onLayout(boolean changed, int l, int t, int r, int b) {
        super.onLayout(changed, l, t, r, b);

//        int imageviewWidth = mImageView.getWidth();
//        int imageviewHidth = imageviewWidth * 13 / 30;
//        mImageView.setLayoutParams(new LinearLayout.LayoutParams(imageviewWidth, imageviewHidth));
    }

    public void setName(String name) {
        mTextView.setText(name);
    }

    public void loadImage(ImageFetcher fetcher, String url) {
        fetcher.loadImage(url, mImageView);
    }
    
    public void setCount(int count){
        mTextView02.setText("共"+count+"张");
    }

    public void setEmptyImage(int resId) {
        mImageView.setImageResource(resId);
    }

}
